import React from 'react';
import { Row, Col } from 'antd';
import DachuangCard from './DachuangCard';

interface Project {
  projectId: number;
  name: string;
  tags: string[];
  description: string;
  likeNum: number;
  shareNum: number;
  lookNum: number;
  likeTrue: boolean;
  createdTime: string;
  image: string | null;
  introduction: string | null;
  advertise: string | null;
  innovation: string | null;
  projectImages: string[] | null;
}

interface DachuangMarketProps {
  projects: Project[];
  loadMoreProjects: () => void;
}

const DachuangMarket: React.FC<DachuangMarketProps> = ({ projects = [], loadMoreProjects }) => {
  return (
    <div className="app-market">
      <Row gutter={[38, 10]}>
        {projects.map((project, index) => (
          <Col key={index} span={12}>
            <DachuangCard
              app={{
                title: project.name,
                description: project.description,
                image: project.image ?? '', // 假设有图片字段，若无则为空
                tags: project.tags,
                likes: project.likeNum,
                views: project.lookNum,
                shares: project.shareNum,
                projectId: project.projectId,
                likeTrue: project.likeTrue
                
              }}
            />
          </Col>
        ))}
      </Row>
      <div className="load-more" style={{ textAlign: 'center', marginTop: '20px' }}>
        <button onClick={loadMoreProjects}>加载更多</button>
      </div>
    </div>
  );
};

export default DachuangMarket;
